<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-if="showSearch" label-width="150px">
      <el-form-item label="检测类型" prop="inspectionType">
        <el-select v-model="queryParams.inspectionType" placeholder="请选择检测类型" clearable>
          <el-option v-for="item in dict.type.inspection_type" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="检测人" prop="checker">
        <el-input
          v-model="queryParams.checker"
          placeholder="请输入SN编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="检查单号" prop="inspectionBillNo">
        <el-input v-model="queryParams.inspectionBillNo" placeholder="请输入检查单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="工单号" prop="workorderCode">
        <el-input v-model="queryParams.workorderCode" placeholder="请输入工单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="预警日期">
        <el-date-picker type="date" v-model="queryParams.startDate" value-format="yyyy-MM-dd" placeholder="开始日期" clearable @keyup.enter.native="handleQuery" />
        <span style="padding: 0px 10px;">至</span>
        <el-date-picker value-format="yyyy-MM-dd" type="date" v-model="queryParams.endDate" placeholder="结束日期" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    <el-table v-loading="loading" :data="recordList">
      <el-table-column type="index" width="55" align="center" />
      <el-table-column label="物料名称" width="200" align="center" prop="itemName" />
      <el-table-column label="物料编码" width="200" align="center" prop="itemCode" />
      <el-table-column label="工单号" width="200" align="center" prop="workorderCode" />
      <el-table-column label="批次" width="200" align="center" prop="batchCode" />
      <el-table-column label="检查单号" width="200" align="center" prop="inspectionBillNo" />
      <el-table-column label="预警内容" align="center" prop="content" />
      <el-table-column label="预警次数" align="center" prop="warnCntForShow" />
      <el-table-column label="检查类型" align="center" prop="inspectionType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.inspection_type" :value="scope.row.inspectionType" />
        </template>
      </el-table-column>
      <el-table-column label="检测人" align="center" prop="updateBy" />
      <el-table-column label="预警时间" align="center" prop="updateTime" />

    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>
<script>
import { listQcInspectionWarn } from '../../../../api/mes/qc/qcInspectionWarn';
export default {
  name: 'QuanlityWarning',
  dicts: ['inspection_type'],
  data() {
    return {
      total: 0,
      showSearch: true,
      recordList: [],
      loading: false,
      queryParams: {
        pageSize: 10,
        pageNum: 1,
      }
    }
  },
  mounted() {
    this.handleQuery();
  },
  methods: {
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleQuery() {
      this.queryParams.pageNum = 1

      this.getList()
    },
    getList() {
      this.loading = true;
      let param = {
        ...this.queryParams
      }
      param.startDate = param.startDate ? param.startDate + ' 00:00:00' : ''
      param.endDate = param.endDate ? param.endDate + ' 23:59:59' : ''
      listQcInspectionWarn(param).then(res => {
        this.recordList = res.data.records
        this.total = res.data.total
        this.loading = false;
      }).catch(e => {
        this.loading = false;
      })
    },

  }
}
</script>
